package main

import (
	"github.com/gin-gonic/gin"
	"gitee.com/gaodihu/gsf/rest"
	"net/http"
)

func main() {
	c := rest.RestConf{
		Host:    "127.0.0.1",
		Port:    8097,
		Verbose: true,
		Mode:    gin.DebugMode,
		Consul: rest.ConsulConf{
			Host: "http://127.0.0.1:8500",
			Key:  "plan-test-gdf",
			Tags: []string{"test"},
		},
	}
	s := rest.MustNewServer(c)


	s.AddRoutes("/api/v1/", []rest.Route{
		{
			Method: http.MethodGet,
			Path:   "test1",
			Handler: func(context *gin.Context) {
				context.Writer.WriteString("test1")
			},
		},
		{
			Method: http.MethodGet,
			Path:   "test2",
			Handler: func(context *gin.Context) {
				context.Writer.WriteString("test2")
			},
		},
	})
	s.AddRoutes("/api/v1/", []rest.Route{
		{
			Method: http.MethodGet,
			Path:   "test3",
			Handler: func(context *gin.Context) {
				context.Writer.WriteString("test3")
			},
		},
		{
			Method: http.MethodGet,
			Path:   "test4",
			Handler: func(context *gin.Context) {
				context.Writer.WriteString("test4")
			},
		},
	}, rest.UseRoutesMiddleWares(func(context *gin.Context) {

	}))
	s.Start()
}
